Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

166
Visualizações
"This" not returning asked value

Im a beginner in Javascript, and I have the following problem ... can someone tell me what I'm doing wrong ? Thanks !

So, go on Instagram, fill the following code in the console:

var open = window.XMLHttpRequest.prototype.open,
    onReadyStateChange;

function openReplacement(method, url, async, user, password) {
    if (url.match(/https:\/\/i\.instagram\.com\/api\/v1\/feed\/user\/[0-9]{1,16}\/story\//g)) {
        console.log(url)
        console.log(this)
        console.log(this.response)
    }
    return open.apply(this, arguments);
}

window.XMLHttpRequest.prototype.open = openReplacement;

So, when I do this and go on a profile, it is supposed to read and print the api response to the get the story data, and it prints the following thing for the console.log(this):

XMLHttpRequest:
    listeners: {load: Array, error: Array, timeout: Array}
    onabort: null
    onerror: function(t)
    onload: function()
    onloadend: null
    onloadstart: null
    onprogress: null
    onreadystatechange: null
    ontimeout: function()
    readyState: 4
    response: "{\"broadcast\":null,\"reel\":{\"id\":…"
    responseText: "{\"broadcast\":null,\"reel\":{\"id\":…"
    responseType: ""
    responseURL: "https://i.instagram.com/api/v1/feed/user/AN_ID/story/"
    responseXML: null
    status: 200
    statusText: ""
    timeout: 10000
    upload: XMLHttpRequestUpload {onloadstart: null, onprogress: null, onabort: null, onerror: null, onload: null, …}
    withCredentials: true

But when the following line comes console.log(this.response), an empty line is printed. And it does this with every values printed in the this upper. I tried to console.log(Object.keys(this)), but same, an empty line is printed ...

If I do this.test = "test there" and do console.log(this.test), "test there" is well printed.

What am I doing wrong ??? Why isn't it returning me the response value from the this ? Thanks for your help !

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda